package app.web.galgame.collects.netant;

import cn.lily.com.exception.YaconException;
import cn.lily.com.lang.Basic;
import cn.lily.com.lang.DeCode;
import cn.lily.web.page.BusinessPage;
import cn.lily.web.widget.sql.TSqlGrid;
import cn.lily.web.widget.standard.TButton;
import cn.lily.web.widget.standard.TButtonPilot;

public class YuiNyaGamePage extends BusinessPage {
	
	@Override
	public void page_onLoad() throws YaconException {
		
		TSqlGrid yuiNyaGrid = sqlGrid("yuiNyaGrid");
		
		String gameNames = DeCode.decode(this.getAttr("gameName")).toUpperCase();
		String[] names = gameNames.split(",");
		String whereSQL = "";
		for(String name:names){
			whereSQL += " or UPPER(GAME_NAME) like '" + Basic.toWhereLike(name)+"'";
		}
		
		if(!"".equals(whereSQL)){
			whereSQL = whereSQL.substring(3);
		}
		
		yuiNyaGrid.setDictTable("LEO_YUINYA_GAL_INFO");
		String sqlString = "select * from ${schema}.LEO_YUINYA_GAL_INFO where "+whereSQL;
		yuiNyaGrid.setCommSqlStr(sqlString);
		yuiNyaGrid.setEdit(true);
			
		yuiNyaGrid.createFieldTitle("GAME_ID").setFieldVisible(false);
		yuiNyaGrid.createFieldTitle("GAME_HREF").setFieldVisible(false);
		yuiNyaGrid.createFieldTitle("GAME_NAME");
		yuiNyaGrid.createFieldTitle("GAME_PRO");
		yuiNyaGrid.createFieldTitle("GAME_TYP");
		yuiNyaGrid.createFieldTitle("GAME_DATE");
		yuiNyaGrid.createFieldTitle("GETCHU_URL").setFieldVisible(false);
		yuiNyaGrid.createFieldTitle("STAND_URL").setFieldVisible(false);
		yuiNyaGrid.createFieldTitle("GAME_MEMO").setFieldVisible(false);
		yuiNyaGrid.createFieldTitle("GAME_THUNDER").setFieldVisible(false);
		yuiNyaGrid.createFieldTitle("GAME_FILE_NAM").setFieldVisible(false);
		yuiNyaGrid.createFieldTitle("GAME_FILE_PWD").setFieldVisible(false);
		yuiNyaGrid.createFieldTitle("GAME_YUN_URLS").setFieldVisible(false);

		TButtonPilot yuiNyaPilot = ButtonPilot("yuiNyaPilot");
		yuiNyaPilot.setPilotIco("/widget/buttonPilot.gif");
		yuiNyaPilot.setPilotText("喵窝网站信息");
		
		
		TButton btn = new TButton("yuiNyaGrid_saveBtn");
		btn.setLabel("确定");
		btn.setIcoPath("glyphicon glyphicon-floppy-saved");
		btn.setViewClick("yuiNyaGrid_saveBtn_click");
		yuiNyaPilot.addButtons(btn);
		
		yuiNyaGrid.setButtonPilot(yuiNyaPilot);
		
		yuiNyaGrid.setTopButtonType("all");
		
		getPage().addElement(yuiNyaGrid);
		
	}
	
	public void refresh() throws YaconException {
		
		TSqlGrid yuiNyaGrid = sqlGrid("yuiNyaGrid");
		
		yuiNyaGrid.setDictTable("LEO_YUINYA_GAL_INFO");
		String sqlString = "select * from ${schema}.LEO_YUINYA_GAL_INFO ";
		yuiNyaGrid.setCommSqlStr(sqlString);
		
		this.setSelfMessage(yuiNyaGrid.getDataElement());
		
	}
	
}
